/**
 * 
 */
package game;

import java.awt.Image;
import java.awt.Rectangle;

import javax.swing.ImageIcon;

/**
 * @author patrick
 *
 */
public class Sprite {

	protected Image image;
	protected String defaultImage;
	protected int width;
	protected int height;
	protected int x;
	protected int y;
	
	/**
	 * @param pImage name of the image
	 * */
	public Sprite (String pImage){
		ImageIcon ii = new ImageIcon(this.getClass().getResource(pImage));
		image = ii.getImage();
		width = image.getWidth(null);
		height = image.getHeight(null);
	}
	
	/**
	 * @param pImage name of the image
	 * */
	public Sprite (String pImage, int xPosition, int yPosition){
		ImageIcon ii = new ImageIcon(this.getClass().getResource(pImage));
		image = ii.getImage();
		width = image.getWidth(null);
		height = image.getHeight(null);
		
		this.x = xPosition;
		this.y = yPosition;
	}

	/**
	 * @return the image
	 */
	public Image getImage() {
		return image;
	}

	/**
	 * @param image the image to set
	 */
	public void setImage(Image image) {
		this.image = image;
	}

	/**
	 * @return the width
	 */
	public int getWidth() {
		return width;
	}

	/**
	 * @param width the width to set
	 */
	public void setWidth(int width) {
		this.width = width;
	}

	/**
	 * @return the height
	 */
	public int getHeight() {
		return height;
	}

	/**
	 * @param height the height to set
	 */
	public void setHeight(int height) {
		this.height = height;
	}

	/**
	 * @return the x
	 */
	public int getX() {
		return x;
	}

	/**
	 * @param x the x to set
	 */
	public void setX(int x) {
		this.x = x;
	}

	/**
	 * @return the y
	 */
	public int getY() {
		return y;
	}

	/**
	 * @param y the y to set
	 */
	public void setY(int y) {
		this.y = y;
	}
	
	/**
	 * @return the rectangle framing the icecube, needed for collision detection
	 * */
	public Rectangle getBounds() {
		return new Rectangle(x, y, width, height);
	}
	
}
